package br.net.woodstock.tickettoride.spring.web.manager;

import javax.faces.event.FacesEvent;

import org.richfaces.event.FileUploadEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import br.net.woodstock.rockframework.web.faces.spring.ViewScope;
import br.net.woodstock.tickettoride.api.manager.ApplicationService;
import br.net.woodstock.tickettoride.api.manager.CertificateService;
import br.net.woodstock.tickettoride.web.jsf.manager.common.AbstractCertificateBean;

@Controller("certificateBean")
@Scope(ViewScope.VIEW_SCOPE)
public class CertificateBean extends AbstractCertificateBean {

	private static final long	serialVersionUID	= -334653897238184433L;

	@Autowired(required = true)
	private ApplicationService	applicationService;

	@Autowired(required = true)
	private CertificateService	certificateService;

	@Override
	public ApplicationService getApplicationService() {
		return this.applicationService;
	}

	@Override
	public CertificateService getCertificateService() {
		return this.certificateService;
	}

	@Override
	protected byte[] getBytesFromUpload(final FacesEvent event) {
		FileUploadEvent e = (FileUploadEvent) event;
		return e.getUploadedFile().getData();
	}

}
